<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button>传统注册事件</button>
    <button>方法监听注册事件</button>
    <script>
        var btns = document.querySelectorAll('button');
        btns[0].onclick = function() {
            console.log('传统方式注册事件');
        }
        btns[0].onclick = function() {
            console.log('传统注册方式-第二次添加相同事件');
        };
        btns[1].addEventListener('click',function(){
            console.log('方法监听方式注册事件');
        });
        btns[1].addEventListener('click',function(){
            console.log('方法监听方式第一次注册相同事件');
        })
    </script>
</body>
</html>